<%-- 
    Document   : vidiGiSitePacienti
    Created on : 17.5.2011, 18:31:
    Author     : Ruzin
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="com.zproekt.entity.Pacient" %>
<%@page import="com.zproekt.servis.OrdinacijaCRUD" %>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<link rel="stylesheet" type="text/css" href="style.css" />

<f:view>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
            <title>JSP Page</title>
        </head>
        <body>
            <div class="head">
               <div class="text">
                    Добродојдовте на страната на стоматолошката ординација
                    
                </div>
                <div class="logo"></div>
             </div> 
            <% 
            if (request.getSession().getValue("permisija") == null){
                response.sendRedirect("index.jsp?error=true");
            }
            String permisija = request.getSession().getValue("permisija").toString();
            if (permisija.equals("user") || permisija.isEmpty()) {
              response.sendRedirect("user.jsp?error=true");
            }
           // out.println("<h2>"+permisija+"</h2>");
        %>
            <% java.util.List<Pacient> lista = OrdinacijaCRUD.getAllPacienti();
                pageContext.setAttribute("pacienti", lista);
            %>
             <%
        if (request.getParameter("success") != null) {
        if (request.getParameter("success").equals("smenatPacient")) {
                out.println("<h1>Пациентот е променет!</h1>");
                }
        if (request.getParameter("success").equals("izbrisanPacient")) {
                out.println("<h1>Пациентот е избришан!</h1>");
                }
               }
        %>
            <h1><h:outputText value="Сите пациенти"/></h1>
            <table border="1">
                <tr>
                    <td>Инфо</td>
                    <td>Име</td>
                    <td>Презиме</td>
                    <td>EMBG</td>
                    <td>Пермисија</td>
                    <td>Инфо</td>
                    <td>Бриши</td>
                </tr>
                <c:forEach var="pacient" items="${pacienti}">
                    <tr>
                        <td>${pacient.id}</td>
                        <td>${pacient.ime}</td>
                        <td>${pacient.prezime}</td>
                        <td>${pacient.embg}</td>
                        <td>${pacient.credential}</td>
                        <td>
                            <form action="pacientUnijaTermini.jsp">
                                <input type="submit" value="Повеќе..."/>
                                <input type="text" name="id" style="display: none" value="${pacient.id}"/>
                            </form>
                        </td>
                        <td>
                            <form action="izbrisiPacient.do">
                                <input type="submit" value="Избриши!"/>
                                <input type="text" name="id" style="display: none" value="${pacient.id}"/>
                            </form>
                        </td>
                    </tr>
                </c:forEach>
            </table>
            <br/>
            <form action="admin.jsp">
                <input type="submit" value="Откажи!"/>
            </form>
            <div class="footer">
                        Copyright Ruzin © 2011
         </div>
        </body>
    </html>
</f:view>
